<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hooks</title>
</head>
<body>
        <h2 class="P5"><a name="_Hooks"><span/></a>Hooks</h2>
        <p class="Text_20_body">
            Hooks provide means to write extensible code. You can define a notification that should be sent to everyone 
            who wants to receive that notification. Such a notification receiver is actually an event handler, marked as hook.
            If not implemented otherwise, usually all receivers are called.
         </p>
         <p>A hook notification can be sent either from within Handler / Library code by using the 
         <code>HookCore::notify($hookName, $context = Array())</code> function or via the <a href="TagLibs.hook.html" target="content">Hook tag</a>.
        </p>
        <p>There are a few pre-defined hooks that always provide means in certain areas to extend/enhance Prails. Those are:
        <table border="1">
        	<thead><tr><th width="120">Hook Name</th><th>Description</th></tr></thead>
        	<tbody>
        		<tr>
        			<td valign="top"><code>"404"</code></td>
        			<td>This hook will be called when a certain page cannot be found. This is true not only in case a content asset page is not found, but also in case an event handler is not found. The first hook handler that returns a string, will be the one used for displaying the 404 page's contents.</td>
        		</tr>
        		<tr>
        			<td valign="top"><code>"global-home"</code></td>
        			<td>Will be called automatically when no event handler is specified in the URL. This usually is the base landing page for a project. The first hook handler that returns a string, will be the one used for displaying the landing page's contents.</td>
        		</tr>
        		<tr>
        			<td valign="top"><code>"builder-init"</code></td>
        			<td>Will be called as soon as the Prails IDE loads up. This is helpful in order to extend the IDE itself - for example for providing a kind of administration interface / backend. The output generated by the notified hook handlers needs to be Javascript code and will usually look like that:
<code>
	Builder.adminRoot = new Ext.tree.TreeNode();
	Builder.adminRoot.appendChild(new Ext.tree.TreeNode({
	    text: "Customers",
	    leaf: true,
	    id: "l-customers",
	    allowChildren: false
	}));
	
	var admin = {
	    id: "qwbuilder_custom-admin",
	    title: "Administration",
	    xtype: "treepanel",
	    region: "south",
	    border: false,
	    width: 150,
	    minSize: 120,
	    maxSize: 540,
	    split: true,
	    autoScroll: true,
	    root: Builder.adminRoot,
	    rootVisible: false,
	    listeners: {
	        dblclick: function(n) {
	        	if (n.id == 'l-customers')
	            Builder.addTab("Admin/customers", "Customers", "tab-l-customers");
	        }
	    }
	};
	
	Builder.addSection(admin);
</code>        			
        			</td> 
        		</tr>
        	</tbody>
        </table>
        </p>
</body>
</html>